package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Wentifenlei;
import com.ruoyi.system.service.IWentifenleiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 问题分类Controller
 * 
 * @author ruoyi
 * @date 2024-08-13
 */
@RestController
@RequestMapping("/system/wentifenlei")
public class WentifenleiController extends BaseController
{
    @Autowired
    private IWentifenleiService wentifenleiService;

    /**
     * 查询问题分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:wentifenlei:list')")
    @GetMapping("/list")
    public TableDataInfo list(Wentifenlei wentifenlei)
    {
        startPage();
        List<Wentifenlei> list = wentifenleiService.selectWentifenleiList(wentifenlei);
        return getDataTable(list);
    }

    /**
     * 导出问题分类列表
     */
    @PreAuthorize("@ss.hasPermi('system:wentifenlei:export')")
    @Log(title = "问题分类", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Wentifenlei wentifenlei)
    {
        List<Wentifenlei> list = wentifenleiService.selectWentifenleiList(wentifenlei);
        ExcelUtil<Wentifenlei> util = new ExcelUtil<Wentifenlei>(Wentifenlei.class);
        util.exportExcel(response, list, "问题分类数据");
    }

    /**
     * 获取问题分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wentifenlei:query')")
    @GetMapping(value = "/{wtflId}")
    public AjaxResult getInfo(@PathVariable("wtflId") Long wtflId)
    {
        return success(wentifenleiService.selectWentifenleiByWtflId(wtflId));
    }

    /**
     * 新增问题分类
     */
    @PreAuthorize("@ss.hasPermi('system:wentifenlei:add')")
    @Log(title = "问题分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Wentifenlei wentifenlei)
    {
        return toAjax(wentifenleiService.insertWentifenlei(wentifenlei));
    }

    /**
     * 修改问题分类
     */
    @PreAuthorize("@ss.hasPermi('system:wentifenlei:edit')")
    @Log(title = "问题分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Wentifenlei wentifenlei)
    {
        return toAjax(wentifenleiService.updateWentifenlei(wentifenlei));
    }

    /**
     * 删除问题分类
     */
    @PreAuthorize("@ss.hasPermi('system:wentifenlei:remove')")
    @Log(title = "问题分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wtflIds}")
    public AjaxResult remove(@PathVariable Long[] wtflIds)
    {
        return toAjax(wentifenleiService.deleteWentifenleiByWtflIds(wtflIds));
    }
}
